<?php
require_once('../model/class.cms_cates.php');
$qicmsCate = new qicmsCate($DB);

if($ts == 'list')
{
$cmsCates = $qicmsCate->getcmsCate();
}

if($ts == 'add')
{
$cname = isset($_POST['cname']) ? $_POST['cname'] : '';
if(!empty($cname)){
$qicmsCate->addcmsCate($cname);
header("Location: index.php?action=cms_cate&ts=list");
}
}

if($ts == 'edit')
{
$cateid = isset($_GET['id']) ? $_GET['id'] : '';
$cmsCateData = $qicmsCate->getOnecmsCate($cateid);
}

if($ts=='update')
{
$cname = isset($_POST['cname']) ? $_POST['cname'] : '';
$cateid = isset($_GET['id']) ? intval($_GET['id']) : '';

$cmsCateData = array(
'cname' => $cname
);

$qicmsCate->updatecmsCate($cmsCateData,$cateid);

header("Location: index.php?action=cms_cate&ts=list");
}

if($ts == 'del')
{
$cateid = isset($_GET['id']) ? $_GET['id'] : '';
$qicmsCate->deletecmsCate($cateid);
header("Location: index.php?action=cms_cate&ts=list");
}

?>